package com.sneakxy.cloudbase.platform.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import com.sneakxy.cloudbase.platform.bean.dto.UploadFileDTO;
import com.sneakxy.cloudbase.platform.utils.web.DataGrid;
import com.sneakxy.cloudbase.platform.utils.web.PageSearch;
import com.sneakxy.cloudbase.platform.utils.web.Response;

/**
 * 
 * @author 潜行的青衣
 * @see
 */
@FeignClient(name = "filemanager-producer", path = "/filemanager/api/filemanager/file")
public interface UploadFileClient {

	@PostMapping("one")
	public Response<UploadFileDTO> one(@RequestParam(name="id") String id);
	
	@PostMapping("datagrid")
	public Response<DataGrid<UploadFileDTO>> datagrid(
			@SpringQueryMap
			PageSearch<String> search, 
			@RequestParam(name="filetype", required=false)
			String filetype);
	
	@PostMapping(value="add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public Response<UploadFileDTO> add(
			@SpringQueryMap
			UploadFileDTO uploadFile,
			@RequestPart(name="file")
			MultipartFile file);
	
	@PostMapping("edit")
	public Response<UploadFileDTO> edit(@SpringQueryMap UploadFileDTO file);
	
	@PostMapping("remove")
	public Response<String> remove(@RequestParam(name="ids") String[] ids);
	
	@PostMapping(value="upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public Response<UploadFileDTO> upload(
			@RequestPart(name="file") MultipartFile file,
			@RequestParam(name="storetype", required=false) String storetype,
			@RequestParam(name="extent") String extent,
			@RequestParam(name="filetype") String filetype,
			@RequestParam(name="name", required = false) String name);
	
	@PostMapping("download")
	public feign.Response download(
			@RequestParam(name="id") 
			String id);
	
	@PostMapping(value="base64")
	public Response<UploadFileDTO> base64(
			@RequestParam(name="source") String source,
			@RequestParam(name="storetype", required=false) String storetype,
			@RequestParam(name="extent") String extent,
			@RequestParam(name="filetype") String filetype,
			@RequestParam(name="name") String name);
	
}
